import Taro from '@tarojs/taro'

const BASE_URL="http://192.168.64.2/"

const post = (url, data) => {
  return new Promise((resolve, reject) => {
    Taro.request({
      url:BASE_URL+url, //仅为示例，并非真实的接口地址
      data:{...data},
      method:"POST",
      header: {
        'content-type': 'application/x-www-form-urlencoded' // 默认值
      },
      success(res) {
        resolve(res.data)
      },
      fail(res) {
        reject(res);
      }
    })
  })


}


const get = (url, data) => {
  return new Promise((resolve, reject) => {
    Taro.request({
      url:BASE_URL+url, //仅为示例，并非真实的接口地址
      data,
      method:"GET",
      header: {
        'content-type': 'application/x-www-form-urlencoded' // 默认值
      },
      success(res) {
        resolve(res.data)
      },
      fail(res) {
        reject(res);
      }
    })
  })


}

export  {
  post,
  get
}